package br.com.android;

import android.content.Context;
import android.view.*;
import android.widget.*;

public class ImageAdapter extends BaseAdapter {
	
	private Context meuContexto;
	private int[] minhasIdsImagens = {
		R.drawable.eric,
		R.drawable.simpsons0,
		R.drawable.southpark
	};
	
	public ImageAdapter(Context c)
	{
		this.meuContexto = c;
	}
	
	public int getCount()
	{
		return this.minhasIdsImagens.length;
	}
	
	public Object getItem(int position)
	{
		return position;
	}
	
	public long getItemId(int position)
	{
		return position;
	}
	
	public View getView(int position, View convertView, ViewGroup parent)
	{
		ImageView imageV = new ImageView(this.meuContexto);
		
		imageV.setImageResource(this.minhasIdsImagens[position]);
		imageV.setScaleType(ImageView.ScaleType.FIT_XY);
		imageV.setLayoutParams(new Gallery.LayoutParams(150, 150));
		
		return imageV;
	}
	
	public float getScale(boolean focused, int offset)
	{
		return Math.max(0, 1.0f / (float)Math.pow(2, Math.abs(offset)));
	}
	
}
